package com.lopo.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@ConditionalOnProperty(name = "com.lopo.loadbalancer.enabled", havingValue = "true")
@Configuration
public class MyLoadbalancerConfig {

    @Bean
    MyLoadbalancer loadbalancer(Environment env, DiscoveryClient discoveryClient) {
        String ip = env.getProperty("lopo.ip-loadbalancer.ipaddress");
        return new MyLoadbalancer(ip, discoveryClient);
    }
}
